#Hyperf Default Dockerfile

FROM hyperf/hyperf:8.0-alpine-v3.15-swoole-v4.8
LABEL maintainer="Jhou Shuai <jhou.shuai@qq.com>" version="1.0" license="MIT" app.name="Hyperf"



# ---------- env settings ----------
##
# --build-arg timezone=UTC
# ARG timezone
#

ARG TZ
ARG APP_ENV
ARG CONTAINER_PACKAGE_URL
#ARG SSH_PRIVATE_KEY
#ARG SSH_PUBLIC_KEY
ARG SCAN_CACHEABLE

ENV APP_ENV=${APP_ENV:-"prod"} \
    TIMEZONE=${TZ:-"Asia/Shanghai"} \
    SCAN_CACHEABLE=(${SCAN_CACHEABLE:-true})

#  install and remove building packages
#     PHPIZE_DEPS="autoconf dpkg-dev dpkg file g++ gcc libc-dev make php8-dev php8-pear pkgconf re2c pcre-dev pcre2-dev zlib-dev libtool automake"

#使用国内的源防止超时
RUN if [ $CONTAINER_PACKAGE_URL ] ; then sed -i "s/dl-cdn.alpinelinux.org/${CONTAINER_PACKAGE_URL}/g" /etc/apk/repositories ; fi


# update
RUN set -ex \
#    && apk update \
    #安装基础服务
    && apk add --no-cache zip \
#    && apk add --no-cache libstdc++ openssl git bash \
#    && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libaio-dev openssl-dev curl-dev \
    # install php extensions
#    && pecl8 install mongodb \
#    && echo "extension=mongodb.so" > /etc/php8/conf.d/mongodb.ini \
    # show php version and extensions \
    # 使用 linux 包管理工具安装 protoc,
#    apk add protobuf \
    # show php version and extensions
    && php -v \
    && php -m \
    && php --ri swoole \
    #  ---------- some config ----------
    && cd /etc/php8 \
    # - config PHP
    && { \
        echo "upload_max_filesize=128M"; \
        echo "post_max_size=128M"; \
        echo "memory_limit=1G"; \
        echo "date.timezone=${TIMEZONE}"; \
    } | tee conf.d/99_overrides.ini \
    # - config timezone
    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
    && echo "${TIMEZONE}" > /etc/timezone \
    # ---------- clear works ----------
    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
    && echo -e "\033[42;37m Build Completed :).\033[0m\n"

WORKDIR /var/www

#COPY . /var/www
#RUN composer install --no-dev -o && php bin/hyperf.php start

EXPOSE 9501-9504

#ENTRYPOINT ["php", "/var/www/bin/hyperf.php", "start"]
